import time

from selenium import webdriver
from selenium.webdriver.common.by import By

#显式等待导包
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
#鼠标事件导包
from selenium.webdriver.common.action_chains import ActionChains
#键盘事件导包
from selenium.webdriver import Keys
import unittest

class A3mall(unittest.TestCase):

    def setup(self):
        self.driver=webdriver.Edge()
        self.driver.maximize_window()
        self.driver.get('')

    def teardown(self):
        time.sleep(4)
        self.driver.quit()

    def test_a3mall_01(self):
        # 登录成功
        # 鼠标单击事件
        sbdj = self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')
        time.sleep(3)
        # 单击
        ActionChains(self.driver).click(sbdj).perform()
        # #双击
        # ActionChains(driver).double_click(sbdj).perform()
        time.sleep(5)
        self.driver.find_element(By.NAME, 'username').send_keys('13811033962')
        time.sleep(3)
        self.driver.find_element(By.NAME, 'password').send_keys('123456')
        time.sleep(10)
        # 点击登录按钮
        self.driver.find_element(By.XPATH, '//*[@id="theForm"]/div[5]/a').click()
        time.sleep(3)

    def test_a3mall_02(self):
        self.test_a3mall_01()
        # 键盘事件回车
        a = self.driver.find_element(By.CLASS_NAME, 'search-input')
        a.send_keys(Keys.ENTER)
        #隐式等待
        self.driver.implicitly_wait(15)
        # 商品详情
        self.driver.find_element(By.XPATH, '/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img').click()
        time.sleep(3)
if __name__ == '__main__':
    unittest.main()